package nz.example.uni;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.Vector;

public class Course implements Serializable {
	
	private static final long serialVersionUID = 6279637410696668916L;
	
	private Collection<Paper> _papers;
	private String courseName;

	public Course()
	{
		_papers = new Vector<Paper>();
	}
	
	public String getCourseName() {
		return courseName;
	}

	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}

	public Collection<Paper> getPapers() {
		return Collections.unmodifiableCollection(_papers);
	}

	public void setPapers(Collection<Paper> papers) {
		_papers = papers;
	}
	
	public void addPaper(Paper paper)
	{
		if(!_papers.contains(paper))
		{
			_papers.add(paper);
		}
	}
	
	public void removePaper(Paper paper)
	{
		_papers.remove(paper);
	}
	
	@Override
	public String toString() {
		return (courseName != null && !courseName.isEmpty()) ? courseName : "Unnamed Course";
	}
	
}
